package com.android.fragmentdemo.adapters
import android.util.Log
import com.hengfoxwolf.commonbase.base.databeans.TurnTableItem
import com.android.fragmentdemo.databinding.RvTurnTableItemLayoutBinding
import com.hengfoxwolf.commonbase.base.adapter.BaseRvAdapter2

class TurnTableAdapter : BaseRvAdapter2<TurnTableItem, RvTurnTableItemLayoutBinding>(RvTurnTableItemLayoutBinding::inflate) {

    override fun bindData(holder: ViewHolder, dataItem: TurnTableItem, position: Int) {
        holder.binding.tvContentTurnTable.apply {
            text = dataItem.content
            setBackgroundColor(context.resources.getColor(dataItem.color))
        }
        Log.d("TurnTableAdapter", "position:${position}")
    }

    override fun listenerWithBinding(binding: RvTurnTableItemLayoutBinding) {
        super.listenerWithBinding(binding)
        Log.d("TurnTableAdapter", "tag:${binding.root.id}")
        binding.tvContentTurnTable.setOnClickListener {
            mOnItemClickListener?.onItemClick(binding.root.tag as TurnTableItem, binding.root.id, binding.root.id)
        }
    }
}